#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

vector<vector<int>> powerset(vector<int> array){
    vector<vector<int>> result {{}};
    for (int n : array){
        
        int lenth = result.size();
        
        for(int i = 0; i < lenth; ++i){
            vector<int> tmp = result[i];
            tmp.push_back(n);

            result.push_back(tmp);
        }
 
    }
    return result;
}

int main(int argc, char const *argv[])
{
    vector<int> v {1, 2, 3};
    auto result = powerset(v);

    for (vector<int> tmp : result){
        cout<<"[";
        for (int n : tmp){
            cout<<n<<",";
        }
        cout<<"]";
    }
    return 0;
}
